package main;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


public class SimulatorProperties {

	private Properties properties;
	
	int MSS;
	int bufferCapacity;
	long Cg;
	long Cs;
	int n1;
	int n2;
	double Tp1;
	double Tp2;
	double TFinterval;
	double TFsize;
	String queueType;
	boolean backTraffic;
	String name;
	double transiente;
	int numRodadasTotal;
	int numColetasTotal;
	double intervalo;
	String pathToSave;
	
	public SimulatorProperties(File file) {
		properties = new Properties();
		try {
			properties.load(new FileInputStream(file));
		} catch (IOException e) {
			e.printStackTrace();
		}
		loadProperties();
	}
	
	public SimulatorProperties(String name) {
		InputStream stream = SimulatorProperties.class.getResourceAsStream(name + ".properties");
		properties = new Properties();
		try {
			properties.load(stream);
		} catch (IOException e) {
			e.printStackTrace();
		}
		loadProperties();
	}
	
	public void loadProperties() {
		this.MSS = Integer.valueOf((String) properties.get("MSS"));
		this.bufferCapacity = Integer.valueOf((String) properties.get("buffer"));
		this.Cg = Long.valueOf((String) properties.get("Cg"));
		this.Cs = Long.valueOf((String) properties.get("Cs"));
		this.n1 = Integer.valueOf((String) properties.get("n1"));
		this.n2 = Integer.valueOf((String) properties.get("n2"));
		this.Tp1 = Double.valueOf((String) properties.get("Tp1"));
		this.Tp2 = Double.valueOf((String) properties.get("Tp2"));
		this.TFsize = Double.valueOf((String) properties.get("TFsize"));
		this.TFinterval = Double.valueOf((String) properties.get("TFinterval"));
		this.queueType = (String) properties.get("queue");
		this.backTraffic = Boolean.valueOf((String) properties.get("backTraffic"));
		this.name = properties.get("name").toString();
		this.transiente = Util.convertSecondsToMillis(Double.valueOf(properties.get("transiente").toString()));
		this.numRodadasTotal = Integer.valueOf(properties.get("numRodadasTotal").toString());
		this.numColetasTotal = Integer.valueOf(properties.get("numColetasTotal").toString());
		this.intervalo = Util.convertSecondsToMillis(Double.valueOf(properties.get("intervalo").toString()));
	}

	public int getMSS() {
		return MSS;
	}

	public void setMSS(int mSS) {
		MSS = mSS;
	}

	public int getBufferCapacity() {
		return bufferCapacity;
	}

	public void setBufferCapacity(int bufferCapacity) {
		this.bufferCapacity = bufferCapacity;
	}

	public long getCg() {
		return Cg;
	}

	public void setCg(long cg) {
		Cg = cg;
	}

	public long getCs() {
		return Cs;
	}

	public void setCs(long cs) {
		Cs = cs;
	}

	public int getN1() {
		return n1;
	}

	public void setN1(int n1) {
		this.n1 = n1;
	}

	public int getN2() {
		return n2;
	}

	public void setN2(int n2) {
		this.n2 = n2;
	}

	public double getTp1() {
		return Tp1;
	}

	public void setTp1(double tp1) {
		Tp1 = tp1;
	}

	public double getTp2() {
		return Tp2;
	}

	public void setTp2(double tp2) {
		Tp2 = tp2;
	}

	public double getTFinterval() {
		return TFinterval;
	}

	public void setTFinterval(double tFinterval) {
		TFinterval = tFinterval;
	}

	public double getTFsize() {
		return TFsize;
	}

	public void setTFsize(double tFsize) {
		TFsize = tFsize;
	}

	public String getQueueType() {
		return queueType;
	}

	public void setQueueType(String queueType) {
		this.queueType = queueType;
	}

	public boolean getBackTraffic() {
		return backTraffic;
	}

	public void setBackTraffic(boolean backTraffic) {
		this.backTraffic = backTraffic;
	}

	public static SimulatorProperties getDefault() {
		return new SimulatorProperties("simulator");
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public double getTransiente() {
		return transiente;
	}

	public void setTransiente(Integer transiente) {
		this.transiente = Util.convertSecondsToMillis(transiente);
	}

	public int getNumeroRodadas() {
		return numRodadasTotal;
	}

	public void setNumeroRodadas(int numRodadaTotal) {
		this.numRodadasTotal = numRodadaTotal;
	}

	public int getNumeroColetas() {
		return numColetasTotal;
	}

	public void setNumeroColetas(int numColetasTotal) {
		this.numColetasTotal = numColetasTotal;
	}

	public double getIntervaloEntreColetas() {
		return intervalo;
	}

	public void setIntervaloEntreColetas(int intervalo) {
		this.intervalo = Util.convertSecondsToMillis(intervalo);
	}

	public String getDirectoryToSave() {
		return pathToSave;
	}

	public void setPathToSave(String pathToSave) {
		this.pathToSave = pathToSave;
	}

}
